package com.example.boot.dlorder.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.boot.dlorder.service.DlOrderServic;
import com.example.boot.util.ResultData;
import com.example.boot.util.ResultUtil;

@RestController
public class DlOrderController {
	@Autowired
	private DlOrderServic dlOrderServic;
	private final static Logger logger = LoggerFactory.getLogger(DlOrderController.class);

	/**
	 * 添加订单
	 * 
	 * @param orderData
	 * @param detailData
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "add/order")
	public ResultData<Object> addOrder(String orderData, String detailData) throws Exception {
		logger.info("添加订单或者购物车|orderData={}|detailData={}|", orderData, detailData);
		return ResultUtil.success(dlOrderServic.saveOrder(orderData, detailData));

	}

	/**
	 * 修改订单
	 * 
	 * @param orderId
	 * @param status
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "update/status")
	public ResultData<Boolean> updateStatus(String orderId, Integer status) throws Exception {
		logger.info("修改订单状态|orderId={}|status={}|", orderId, status);
		return ResultUtil.success(dlOrderServic.updateStatus(orderId, status));
	}

}
